package com.hmdp.controller;


import com.hmdp.dto.Result;
import com.hmdp.service.IFollowService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 虎哥
 * @since 2021-12-22
 */
@RestController
@RequestMapping("/follow")
public class FollowController {

    @Resource
    private IFollowService followService;

    /**
     * 关注/取关用户
     * @param followedId
     * @param isFollow
     * @return
     */
    @PutMapping("/{id}/{isFollow}")
    public Result followUser(@PathVariable("id") Long followedId, @PathVariable("isFollow") Boolean isFollow){

        return followService.followUser(followedId, isFollow);
    }

    /**
     * 当前用户是否关注过
     * @param followedId
     * @return
     */
    @GetMapping("/or/not/{id}")
    public Result isFollow(@PathVariable("id") Long followedId){
        return followService.isFollow(followedId);
    }

    @GetMapping("/common/{id}")
    public Result commonFollow(@PathVariable("id") Long current){

        return followService.commonFollow(current);

    }

}
